#pragma once

#include "Common/AtomicVal.h"

struct ServerData
{
	UInt32		_id;
	std::string	_name;
	UInt8		_type;
	std::string	_innterIp;
	std::string	_outerIp;
	UInt16		_port;
	UInt16		_roomCount;
	UInt16		_onlineCount;

	ServerData()
		: _id( 0 ), _type( 0 ), _port( 0 ), _roomCount( 0 ), _onlineCount( 0 )
	{
	}
};

class Stream;
class ServerClient
{
public:
	ServerClient();
	~ServerClient();

public:
	inline UInt32 getId()	{ return _serverData._id; }

public:
	void setServerData( ServerData& sd ) { _serverData = sd; }

public:
	bool isConned();
	UInt32 getRoomCount();
	UInt32 getOnlineCount();
	UInt32 incRoomCount();
	UInt32 decRoomCount();
	UInt32 incOnlineCount();
	UInt32 decOnlineCount();

	void syncServerData(UInt32, UInt32);
	void saveServerData();

	std::string getServerIp()	{ return _serverData._outerIp; }
	UInt16 getServerPort()		{ return _serverData._port;	}

public:
	inline void setSessionID( Int32 ss )	{ _session = ss;	}
	inline Int32 getSessionID()				{ return _session;	}

public:
	void send(Stream&);
	void send(void *, UInt16);

protected:
	AtomicVal<Int32>	_session;
	ServerData			_serverData;
};